package com.qf.controller;

import com.qf.entity.TbTestpaperQuestion;
import com.qf.service.QuestionService;
import com.qf.service.TestpaperService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/testpaper")
public class TestpaperController {

    @Autowired
    QuestionService questionService;

    @Autowired
    TestpaperService testpaperService;

    /**
     * 根据试卷编号查询所有试题
     * @param testpaperId 试卷id
     * @return
     */
    @GetMapping
    public ResultMsg findById(Integer testpaperId) {
        return questionService.findByIdAndType(testpaperId);
    }

    /**
     * 添加题目ID,类型,试卷id到表
     * @param tbTestpaperQuestion
     * @return
     */
    @PostMapping("/addPaper")
    public ResultMsg addPaper(@RequestBody TbTestpaperQuestion tbTestpaperQuestion){
        return testpaperService.addTestPaper(tbTestpaperQuestion);
    }

}
